package com.ruoyi.web.controller.jiuyezu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.jiuyezu.domain.Classes;
import com.ruoyi.jiuyezu.service.ClassesService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班级，记录班级的基本信息Controller
 * 
 * @author wyj
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/jiuyezu/classes")
public class ClassesController extends BaseController
{
    @Autowired
    private ClassesService jiuyezuClassesService;

    /**
     * 查询班级，记录班级的基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('jiuyezu:classes:list')")
    @GetMapping("/list")
    public TableDataInfo list(Classes classes)
    {
        startPage();
        List<Classes> list = jiuyezuClassesService.selectJiuyezuClassesList(classes);
        return getDataTable(list);
    }

    /**
     * 导出班级，记录班级的基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('jiuyezu:classes:export')")
    @Log(title = "班级，记录班级的基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Classes classes)
    {
        List<Classes> list = jiuyezuClassesService.selectJiuyezuClassesList(classes);
        ExcelUtil<Classes> util = new ExcelUtil<Classes>(Classes.class);
        util.exportExcel(response, list, "班级，记录班级的基本信息数据");
    }

    /**
     * 获取班级，记录班级的基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiuyezu:classes:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jiuyezuClassesService.selectJiuyezuClassesById(id));
    }

    /**
     * 新增班级，记录班级的基本信息
     */
    @PreAuthorize("@ss.hasPermi('jiuyezu:classes:add')")
    @Log(title = "班级，记录班级的基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Classes classes)
    {
        return toAjax(jiuyezuClassesService.insertJiuyezuClasses(classes));
    }

    /**
     * 修改班级，记录班级的基本信息
     */
    @PreAuthorize("@ss.hasPermi('jiuyezu:classes:edit')")
    @Log(title = "班级，记录班级的基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Classes classes)
    {
        return toAjax(jiuyezuClassesService.updateJiuyezuClasses(classes));
    }

    /**
     * 删除班级，记录班级的基本信息
     */
    @PreAuthorize("@ss.hasPermi('jiuyezu:classes:remove')")
    @Log(title = "班级，记录班级的基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jiuyezuClassesService.deleteJiuyezuClassesByIds(ids));
    }
}
